import express from "./express/index.js";
// import express from "express";
import path from "path";
import ejs from "ejs";
const app = express();

app.use(express.static(import.meta.dirname));

// 当前的template 为模板路径进行查找
app.set("views", path.resolve("template"));
app.set("view engine", "html"); // 节省html后缀  render('index')

// console.log(app.get("views"), app.get("view engine"));

app.engine(".html", ejs.__express); // 告诉模板引擎用的是ejs渲染函数来 渲染

app.get("/", async function (req, res, next) {
  //   res.render("index", { username: "jw" });
  res.send({ name: "jw" });
});

// app.get("/package.json", async function (req, res, next) {
//   //   res.render("index", { username: "jw" });
//   res.sendFile(path.resolve("package.json"));
// });

app.listen(3000);
